
type CalcType = (num1: number, num2: number) => number

const calc: CalcType = (a, b) => {
  return a + b
}
// calc(10, 20)

// 2.函数的调用
function sum(num1: number, num2: number) {
  return num1 + num2
}

function foo(num1: number, num2: number, calc: CalcType) {
  return calc(num1, num2)
}

foo(10, 20, sum)

function mul(num1: number, num2: number) {
  return num1 * num2
}

mul(10, 20)

// 3.使用匿名函数
function calcFn(calc: CalcType) {
  const num1 = 10
  const num2 = 20
  const res = calc(num1, num2)
  console.log(res)
}

calcFn(function(num1, num2) {
  return num1 - num2
})

export {}